From 1813dfa417134c05c5ba62f6abff9e0629666dfc Mon Sep 17 00:00:00 2001 From: Hollis Blanchard Date: Thu, 2 Aug 2007 09:50:55 -0500 Subject: [PATCH] [POWERPC][XEN] Commit missing multiboot files. Signed-off-by: Hollis Blanchard --- xen/arch/powerpc/multiboot2.c | 67 +++++++++++++++++++++++ xen/include/asm-powerpc/boot.h | 46 ++++++++++++++++ xen/include/xen/multiboot2.h | 99 ++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 xen/arch/powerpc/multiboot2.c create mode 100644 xen/include/asm-powerpc/boot.h create mode 100644 xen/include/xen/multiboot2.h diff --git a/xen/arch/powerpc/multiboot2.c b/xen/arch/powerpc/multiboot2.c new file mode 100644 index 0000000000..fb16738ba0 --- /dev/null +++ b/xen/arch/powerpc/multiboot2.c @@ -0,0 +1,67 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2006, 2007 + * + * Authors: Hollis Blanchard + */ + +#include +#include +#include +#include +#include + +static struct mb2_tag_module *mb2_tag_mod_find(struct mb2_tag_header *tags, + const char *type) +{ + struct mb2_tag_header *tag; + + for_each_tag(tag, tags) { + if (tag->key == MB2_TAG_MODULE) { + struct mb2_tag_module *mod = (struct mb2_tag_module *)tag; + if (!strcmp((char *)mod->type, type)) + return mod; + } + } + return NULL; +} + +void parse_multiboot(ulong tags_addr) +{ + struct mb2_tag_header *tags = (struct mb2_tag_header *)tags_addr; + struct mb2_tag_module *mod; + + if (tags->key != MB2_TAG_START) + return; + + mod = mb2_tag_mod_find(tags, "kernel"); + if (mod) { + xen_cmdline = (char *)mod->cmdline; + } + + mod = mb2_tag_mod_find(tags, "dom0"); + if (mod) { + dom0_addr = mod->addr; + dom0_len = mod->size; + dom0_cmdline = (char *)mod->cmdline; + } + + mod = mb2_tag_mod_find(tags, "initrd"); + if (mod) { + initrd_start = mod->addr; + initrd_len = mod->size; + } +} diff --git a/xen/include/asm-powerpc/boot.h b/xen/include/asm-powerpc/boot.h new file mode 100644 index 0000000000..462b891bc5 --- /dev/null +++ b/xen/include/asm-powerpc/boot.h @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2007 + * + * Authors: Hollis Blanchard + */ + +#ifndef _ASM_BOOT_H +#define _ASM_BOOT_H + +/* a collection of interfaces used during boot. */ + +extern void boot_of_init(ulong, ulong); +extern void *boot_of_devtree(void); +extern void boot_of_serial(void *); +extern void boot_of_finish(void); +extern int boot_of_mem_avail(int pos, ulong *startpage, ulong *endpage); + +extern void parse_multiboot(ulong tags_addr); + +extern void memory_init(void); + +extern char *xen_cmdline; +extern ulong dom0_addr; +extern ulong dom0_len; +extern char *dom0_cmdline; +extern ulong initrd_start; +extern ulong initrd_len; + +/* From linker script. */ +extern char builtin_cmdline[]; + +#endif diff --git a/xen/include/xen/multiboot2.h b/xen/include/xen/multiboot2.h new file mode 100644 index 0000000000..3014bba1fb --- /dev/null +++ b/xen/include/xen/multiboot2.h @@ -0,0 +1,99 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2006, 2007 + * + * Authors: Hollis Blanchard + * + */ + +#ifndef _MULTIBOOT2_H_ +#define _MULTIBOOT2_H_ + +/* How many bytes from the start of the file we search for the header. */ +#define MB2_HEADER_SEARCH 8192 + +/* The magic field should contain this. */ +#define MB2_HEADER_MAGIC 0xe85250d6 + +/* Passed from the bootloader to the kernel. */ +#define MB2_BOOTLOADER_MAGIC 0x36d76289 + +#include + +#define for_each_tag(_tag, _tags) \ + for ((_tag) = (_tags); \ + ((_tag)->key != MB2_TAG_END && (_tag)->key != 0); \ + (_tag) = (void *)(_tag) + (_tag)->len) + +typedef uint32_t mb2_word; + +struct mb2_header +{ + uint32_t magic; +}; + +struct mb2_tag_header +{ + uint32_t key; + uint32_t len; +}; + +#define MB2_TAG_START 1 +struct mb2_tag_start +{ + struct mb2_tag_header header; + mb2_word size; /* Total size of all mb2 tags. */ +}; + +#define MB2_TAG_NAME 2 +struct mb2_tag_name +{ + struct mb2_tag_header header; + char name[1]; +}; + +#define MB2_TAG_MODULE 3 +struct mb2_tag_module +{ + struct mb2_tag_header header; + mb2_word addr; + mb2_word size; + unsigned char type[36]; + unsigned char cmdline[1]; +}; + +#define MB2_TAG_MEMORY 4 +struct mb2_tag_memory +{ + struct mb2_tag_header header; + mb2_word addr; + mb2_word size; + mb2_word type; +}; + +#define MB2_TAG_UNUSED 5 +struct mb2_tag_unused +{ + struct mb2_tag_header header; +}; + +#define MB2_TAG_END 0xffff +struct mb2_tag_end +{ + struct mb2_tag_header header; +}; + +#endif -- 2.30.2